<!DOCTYPE html>
<html lang="en">


<head>

    <meta charset="utf-8">
    <title>字符串位置方法</title>

</head>


<body>

    <script type="text/javascript">
        var str = "hello world";
        console.log(str.indexOf("o"));//4 
        console.log(str.lastIndexOf("o"));//7 
        console.log(str.indexOf("o", 6));//7 
        console.log(str.lastIndexOf("o", 6));//4 
    </script>

</body>

</html>